/**
 *Copyright (c) 2024 watereyes
 * safetymanagement is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */
package com.koron.report.mapper.statistics;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 应急预案演练完成率
 */
public interface ComRateEmergPlanDrillMapper {

    /**
     * 演练评估：按部门
     *
     * @param startDate
     * @param stopDate
     * @return
     */
    @Select("select DISTINCT da.sponsor_dept_code AS code,da.sponsor_dept_name AS codeName, da.drill_plan_id AS drillPlanId " +
            "from drill_assessment da where da.drill_plan_id is not null " +
            "AND da.drill_time between #{startDate} and #{stopDate}")
    List<Map<String, String>> statisticsExerciseEvaluationTotalDept(@Param("startDate") Date startDate, @Param("stopDate") Date stopDate);

    /**
     * 应急演练：按部门
     * @param startDate
     * @param stopDate
     * @return
     */
    @Select("select dp.sponsor_dept_code AS code,dp.sponsor_dept_name AS codeName, dp.id AS drillPlanId " +
            "from drill_plan dp where (dp.is_remove = 0 OR dp.is_remove is null) " +
            "AND dp.drill_time between #{startDate} and #{stopDate}")
    List<Map<String, String>> statisticsEmergencyExerciseTotalDept(@Param("startDate") Date startDate, @Param("stopDate") Date stopDate);

    /**
     * 演练评估：按公司
     *
     * @param startDate
     * @param stopDate
     * @return
     */
    @Select("select DISTINCT da.corp_code AS code, da.drill_plan_id AS drillPlanId " +
            "from drill_assessment da where da.drill_plan_id is not null " +
            "AND da.drill_time between #{startDate} and #{stopDate}")
    List<Map<String, String>> statisticsExerciseEvaluationTotalCompany(@Param("startDate") Date startDate, @Param("stopDate") Date stopDate);

    /**
     * 应急演练：按公司
     * @param startDate
     * @param stopDate
     * @return
     */
    @Select("select dp.corp_code AS code, dp.id AS drillPlanId " +
            "from drill_plan dp where (dp.is_remove = 0 OR dp.is_remove is null) " +
            "AND dp.drill_time between #{startDate} and #{stopDate}")
    List<Map<String, String>> statisticsEmergencyExerciseTotalCompany(@Param("startDate") Date startDate, @Param("stopDate") Date stopDate);
}
